package com.ruoyi.web.controller.job;

import com.alibaba.fastjson2.JSON;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.domain.HomeJobDomain;
import com.ruoyi.system.service.impl.HomeJobServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
public class HomeJobController extends BaseController {

    @Autowired
    private HomeJobServiceImpl homeJobService;

    @PostMapping("/home/job/count")
    public AjaxResult homeJobCount() {
        long stime = System.currentTimeMillis();
        HomeJobDomain homeJobDomain = homeJobService.homeJobCount(getUserId());
        long etime = System.currentTimeMillis();
        System.out.printf("执行时长：%d 毫秒.", (etime - stime));
        log.info("当前用户:{} 作业票统计结果:{}", getUserId(), JSON.toJSONString(homeJobDomain));
        return AjaxResult.success(homeJobDomain);
    }

}
